package GUI;

import javax.swing.*;

public class PN_Control_Panel extends JPanel {

	private static final long serialVersionUID = 6727183907188822920L;
	private PN_Draw_Panel drawPanel;
	
	JButton oneStep;
	JButton Running;
	
	public PN_Control_Panel(PN_Draw_Panel dp) {
		this.setBorder(BorderFactory.createTitledBorder("Control"));
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		this.drawPanel = dp;

		oneStep = new JButton("One Step");
		Running = new JButton("Running");
		
		this.add(oneStep);
		this.add(Running);
		
		oneStep.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				Running.setText("Running");
				drawPanel.SetOneStep();
			}
		});
		Running.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
            	JButton button = (JButton)evt.getSource();
            	if (button.getText() == "Running") {
            		drawPanel.Start();
            		button.setText("Stop");
            	} else {
            		drawPanel.Suspend();
            		button.setText("Running");
            	}
            }
		});
	}

}
